package com.pennywise.controller;

import com.pennywise.common.response.Result;
import com.pennywise.model.ChatMessage;
import com.pennywise.service.AIService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@Tag(name = "AI分析")
@RestController
@RequestMapping("/api/ai")
@RequiredArgsConstructor
public class AIController {
    
    private final AIService aiService;
    
    @Operation(summary = "获取消费分析建议")
    @GetMapping("/analysis")
    public Result<String> getSpendingAnalysis() {
        return Result.success(aiService.analyzeSpending());
    }

    @Operation(summary = "发送消息给AI助手")
    @PostMapping("/chat")
    public Result<ChatMessage> sendMessage(@RequestBody ChatMessage message) {
        return Result.success(aiService.processMessage(message));
    }

    @Operation(summary = "获取AI对话历史")
    @GetMapping("/history")
    public Result<List<Map<String, String>>> getHistory() {
        return Result.success(aiService.getHistory());
    }
}